﻿namespace Corporation.Project
{
    public class AutoMapperConfiguration : AutoMapperTupleBase
    {
        /// <summary>
        /// 初始化一个权限模块DTO实体映射 <see cref="AutoMapperConfiguration"/> 的新实例
        /// </summary>
        /// <param name="provider">服务提供者</param>
        public AutoMapperConfiguration(IServiceProvider provider)
        {
            ServiceProvider = provider;
        }

        /// <summary>
        /// 获取 服务提供者
        /// </summary>
        protected IServiceProvider ServiceProvider { get; }

        /// <summary>
        /// 创建对象映射
        /// </summary>
        public override void CreateMap()
        {
            CreateMap<ArticleInputDto, Article>();
            CreateMap<Article, ArticleOutputDto>();
        }

        //private static FileInfo[] GetFileInfos(IServiceProvider provider, long[] fileIds)
        //{
        //    FileInfo[] fileInfos = [];
        //    using IServiceScope scope = provider.CreateScope();
        //    var fileRepository = scope.ServiceProvider.GetService<IRepository<FileEntity, long>>();
        //    var fileEntities = fileRepository.QueryAsNoTracking().Where(a => fileIds.Contains(a.Id)).ToList();
        //    if (fileEntities.Count > 0)
        //    {
        //        fileInfos = fileEntities.Select(a => a.MapTo<FileInfo>()).ToArray();
        //    }
        //    return fileInfos;
        //}

    }
}
